package com.hnust.dao;

import com.hnust.domain.QuestionAnswers;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

@Mapper
@Repository
public interface GetAnswerDao {

    //获取题目内容、解析、分数
    @Select(" SELECT content text,analysis,score\n" +
            " FROM question\n" +
            " WHERE que_id = #{questionId}")
    @ResultType(QuestionAnswers.class)
    QuestionAnswers getQuestionMsg(String questionId);

    //获取选择题选项内容
    @Select("select aa.content \n" +
            " from alternative_answer aa\n" +
            " where aa.que_id = #{questionId}\n" +
            " ORDER BY content")
    @ResultType(String.class)
    String[] getOptionQuestionMsg(String questionId);


    //获取正确答案
    @Select("select aa.content answer\n" +
            " from alternative_answer aa\n" +
            " where aa.que_id = #{questionId} and aa.`right` = 1 ")
    @ResultType(String.class)
    ArrayList<String> getCorrectAnswer(String questionId);

   //获取学生一张卷子的答案串
    @Select("select rd.que_res result\n" +
            " from result_detail rd\n" +
            " where rd.studentId =#{studentId} and rd.testId = #{testId}\n" +
            "\n")
    @ResultType(String.class)
    String getStuAnswer(String testId,String studentId);
}
